﻿#include "pch.h"
using namespace std;

int highestBitPosition(int n) {
	if (n <= 0) {
		std::cerr << "Invalid input. Please provide a positive integer." << std::endl;
		return -1; // 返回一个表示错误的值
	}

	int position = 0;

	while (n >>= 1) {
		position++;
	}

	return position;
}

TEST(math, m1) {
	int number = 100; // 101010 in binary, so the highest bit position is 5
	int result = highestBitPosition(number);

	std::cout << "The highest bit position in " << number << " is: " << result << std::endl;
}
